import { View } from "../../../mvc/core/View";
import { IToolTipItem } from "../../../../com/mui/manager/IToolTipItem";
import { LayerManager } from "../../manager/LayerManager";
import { SkillItem } from "../skill/SkillItem";
import { FishLearnWindow } from "./FishLearnWindow";
import { ObjectPool } from "../../../../com/gengine/utils/pools/ObjectPool";
import { UiFlyDispalyObjectUtil } from "../uiIconBtn/UiFlyDispalyObjectUtil";
import { TweenLite } from "../../../../com/greensock/TweenLite";
import { SkillLevelGetInfo } from "../../resource/info/SkillLevelGetInfo";
import { ToolTipsManager } from "../../../../com/mui/manager/ToolTipsManager";
type int = number;
//class FishIconView
    
    export  class FishIconView extends View implements IToolTipItem
    {
        constructor()
        {
            super();
            this.layer = LayerManager.uiLayer;
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this._skillItem = new SkillItem();
            this._skillItem.x = 2;
            this._skillItem.y = 2;
            this._skillItem.isDragAble = false;
            addChild(this._skillItem);
            this.addEventListener(flash.events.MouseEvent.CLICK, this.onGetFishSkill);
            return;
        }

        /* internal  */onGetFishSkill(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (!this._fishLearnWindow) 
            {
                this._fishLearnWindow = new FishLearnWindow();
            }
            this._fishLearnWindow.updateData(this._skillInfo);
            this._fishLearnWindow.show();
            this._fishLearnWindow.isCanLearn = this._isCanLearn;
            return;
        }

        public showLightMask(): void
        {
            this._isCanLearn = true;
            if (!this._lightMask) 
            {
                this._lightMask = ObjectPool.getObject(LightMask);
                this._lightMask.x = 0;
                this._lightMask.y = 0;
                this._lightMask.transform.matrix = new Object /* flash.geom.Matrix */();
                this._lightMask.scaleX = 42 / 42.5;
                this._lightMask.scaleY = 42 / 42.5;
                this._lightMask.play();
                this.addChild(this._lightMask);
            }
            if (!this._isMove) 
            {
                this.flyToStage();
            }
            return;
        }

        /* internal  */flyToStage(): void
        {
            this._isMove = true;
            var loc1=UiFlyDispalyObjectUtil.instance.getPoint(this);
            TweenLite.to(this, 3, {"x": loc1.x, "y": loc1.y, "delay": 2, "onComplete": this.levelAwardFlyEnd});
            return;
        }

        /* internal  */levelAwardFlyEnd(): void
        {
            this._isMove = false;
            UiFlyDispalyObjectUtil.instance.resetPoints();
            return;
        }

        public hideLightMask(): void
        {
            UiFlyDispalyObjectUtil.instance.reducePoint(this);
            this._isCanLearn = false;
            if (this._lightMask) 
            {
                if (this._lightMask.parent) 
                {
                    this._lightMask.parent.removeChild(this._lightMask);
                }
                this._lightMask.x = 0;
                this._lightMask.y = 0;
                this._lightMask.width = 40;
                this._lightMask.height = 40;
                this._lightMask.stop();
                ObjectPool.disposeObject(this._lightMask);
                this._lightMask = null;
            }
            return;
        }

        public updateData(arg1: SkillLevelGetInfo): void
        {
            this._skillInfo = arg1;
            this._skillItem.data = this._skillInfo.skillInfo;
            this.toolTipData = arg1.toolTipData;
            this.hideLightMask();
            return;
        }

        public stageResize(arg1: int, arg2: int): void
        {
            this.x = arg1;
            this.y = arg2;
            return;
        }

        public FishIconView.get isMove(): Boolean
        {
            return this._isMove;
        }

        public /* override */ hide(): void
        {
            this._isMove = false;
            UiFlyDispalyObjectUtil.instance.reducePoint(this);
            this.hideLightMask();
            this._skillInfo = null;
            super.hide();
            return;
        }

        public FishIconView.get toolTipData()
        {
            return this._toolTipData;
        }

        public set toolTipData(arg1)
        {
            if (arg1 == null || arg1 == "") 
            {
                ToolTipsManager.unregister(this);
            }
            else 
            {
                ToolTipsManager.register(this);
            }
            this._toolTipData = arg1;
            return;
        }

        public static get instace(): FishIconView
        {
            if (!FishIconView._instance) 
            {
                FishIconView._instance = new FishIconView();
            }
            return FishIconView._instance;
        }

        /* internal */ /* var */_skillItem: SkillItem;

        /* internal */ /* var */_lightMask: LightMask;

        /* internal */ /* var */_skillInfo: SkillLevelGetInfo;

        /* internal */ /* var */_isMove: Boolean;

        /* internal */ /* var */_isCanLearn: Boolean=false;

        /* internal */ /* var */_fishLearnWindow: FishLearnWindow;

        /* internal */ /* var */_toolTipData;

        /* internal */ static /* var */_instance: FishIconView;
    }
